package com.cn.androidpicker;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.cn.androidpicker.bean.CityData;
import com.cn.androidpicker.bean.DistrictData;
import com.cn.androidpicker.bean.ProvincesData;
import com.cn.androidpicker.bean.TownData;
import com.cn.androidpicker.utils.CitySelectUtils;

public class MainActivity extends AppCompatActivity {
    TextView tv_city;
    String sheng = "";
    String shi = "";
    String qu = "";
    String xiang = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv_city = findViewById(R.id.tv_city);
        tv_city.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectCity();
            }
        });
    }

    private void selectCity() {
        CitySelectUtils showProbincePickviewUtil = new CitySelectUtils(this);

        showProbincePickviewUtil.setOnAddressChoosedListener(new CitySelectUtils.OnAddressChoosedListener() {
            @Override
            public void onChoosed(ProvincesData provinceBean, CityData cityBean, DistrictData districtBean, TownData townData) {
//                        addressBean.setProvince(provinceBean.getId());
//                        addressBean.setCity(cityBean.getId());
//                        addressBean.setDistrict(districtBean.getId());
                sheng = provinceBean.getName();
                shi = cityBean.getName();
                qu = districtBean.getName();
            }

            @Override
            public void onAddressChoosed(String address) {
                tv_city.setText(address + "");
            }
        });
        showProbincePickviewUtil.startShowChooseDialog();
    }
}